/*
 * utility methods used in the code
 */
var Util = new Class({
  findMaximumDivider: function(number,divider){
      var ooo=parseInt(number/divider);
      return ooo*divider;
  },
  rePositionCoordinate: function(number,divider){
      var modulo=number%divider;
      var maxDivider=parseInt(number/divider);
      if(modulo==0)
          return number;
  	if(modulo>(4/10)*divider && modulo<(6/10)*divider){
            if(maxDivider%2==0){
                return maxDivider*divider;
            } else
  		return number;
  	} else {
  		if(modulo<=(4/10)*divider){
  			return maxDivider*divider;
  		}
  		if(modulo>=(6/10)*divider){
  			return (maxDivider+1)*divider;
  		}
  	}
  },
  getZoneAtPoint: function(x,y){
      if(x>=game.worldWidth)
          x=game.worldWidth-1;
      if(y>=game.worldHeight)
          y=game.worldHeight-1;
      return game.zones[parseInt(x/game.standardWidth)][parseInt(y/game.standardHeight)];
  },
  removeElementFromArray: function(el,array){
      var idx=-1;
        for(var i=0;i<array.length;i++){
            if(array[i]==el){
                idx=i;
                break;
            }
        }
        if(idx!=-1)
          array.splice(i,1);
  }
});
